<template>
	<view class="page chat-system">
		<view class="header">
			<text class="title">{{title}}</text>
		</view>
		<div class="container">
			<scroll-view class="scroll-box" scroll-y="true" upper-threshold="200">
				<web-view v-if="contentType==1" :src="externLink"></web-view>
				<up-parse v-else :content="richText"></up-parse>
			</scroll-view>
		</div>
	</view>
</template>

<script>
	import { Base64 } from 'js-base64';

	export default {
		data() {
			return {
				title: "",
				contentType: 0,
				richText: "",
				externLink: ""
			}
		},
		methods: {
			onNavBack() {
				uni.navigateBack();
			},
			init(id, title) {
				this.$http({
					url: '/message/system/content?id=' + id,
					method: 'GET',
				}).then(msgInfo => {
					this.title = title;
					this.richText = Base64.decode(msgInfo.richText);
					this.externLink = msgInfo.externLink;
					this.contentType = msgInfo.contentType;
					this.isShow = true;
				})
			},
		},
		onLoad(options) {
			console.log(options)
			this.init(options.id, options.title);
		}
	}
</script>

<style lang="scss" scoped>
	.chat-system {
		position: relative;
		border: #dddddd solid 1px;
		display: flex;
		flex-direction: column;

		.header {
			display: flex;
			justify-content: center;
			align-items: center;
			height: 60rpx;
			padding: 5px;
			background-color: #f8f8f8;
			border: #dddddd solid 1px;
			
			.title {
				padding: 0 50rpx;
				line-height: 50px;
				font-size: 40rpx;
				font-weight: 600;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
			}
		}

		.container {
			flex: 1;
			padding: 40rpx;
			border: #dddddd solid 1px;
			overflow: hidden;
			position: relative;
			background-color: #f6f6f6;
			
			.scroll-box {
				height: 100%;
			}
		}
	}
</style>